if exist C:\Windows\SysWOW64 goto win64
cd bin\win32
goto winXY

:win64
cd bin\win64

:winXY

@rem Gray levels

filter /s /Mask /MaskSize 2 ..\..\images\filter\f_test.txt mask2.txt /Format TXT#plain
filter /s /Mask /MaskSize 3 ..\..\images\filter\f_test.txt mask3.txt /Format TXT#plain
filter /s /Mask /MaskSize 4 ..\..\images\filter\f_test.txt mask4.txt /Format TXT#plain
filter /s /Mask /MaskSize 5 ..\..\images\filter\f_test.txt mask5.txt /Format TXT#plain

gcomp mask2.txt ..\..\images\filter\f_mask2.txt
@if errorlevel 1 goto errorf
gcomp mask3.txt ..\..\images\filter\f_mask3.txt 
@if errorlevel 1 goto errorf
gcomp mask4.txt ..\..\images\filter\f_mask4.txt 
@if errorlevel 1 goto errorf
gcomp mask5.txt ..\..\images\filter\f_mask5.txt 
@if errorlevel 1 goto errorf


filter /s /Median /MaskSize 2 ..\..\images\filter\f_test.txt medi2.txt /Format TXT#plain
filter /s /Median /MaskSize 3 ..\..\images\filter\f_test.txt medi3.txt /Format TXT#plain
filter /s /Median /MaskSize 4 ..\..\images\filter\f_test.txt medi4.txt /Format TXT#plain
filter /s /Median /MaskSize 5 ..\..\images\filter\f_test.txt medi5.txt /Format TXT#plain
filter /s /Median /MaskSize 6 ..\..\images\filter\f_test.txt medi6.txt /Format TXT#plain
filter /s /Median /MaskSize 7 ..\..\images\filter\f_test.txt medi7.txt /Format TXT#plain

gcomp medi2.txt ..\..\images\filter\f_medi2.txt 
@if errorlevel 1 goto errorf
gcomp medi3.txt ..\..\images\filter\f_medi3.txt
@if errorlevel 1 goto errorf
gcomp medi4.txt ..\..\images\filter\f_medi4.txt
@if errorlevel 1 goto errorf 
gcomp medi5.txt ..\..\images\filter\f_medi5.txt 
@if errorlevel 1 goto errorf
gcomp medi6.txt ..\..\images\filter\f_medi6.txt
@if errorlevel 1 goto errorf
gcomp medi7.txt ..\..\images\filter\f_medi7.txt
@if errorlevel 1 goto errorf


gconvert /s /Dilatation ..\..\images\filter\Dilat.txt dilat1.txt /Format TXT#plain
@if errorlevel 1 goto errorf
gconvert /s /Dilatation dilat1.txt dilat2.txt /Format TXT#plain
@if errorlevel 1 goto errorf
gconvert /s /Dilatation dilat2.txt dilat3.txt /Format TXT#plain
@if errorlevel 1 goto errorf

gcomp dilat1.txt ..\..\images\filter\Dilat1.txt
@if errorlevel 1 goto errorf
gcomp dilat2.txt ..\..\images\filter\Dilat2.txt
@if errorlevel 1 goto errorf
gcomp dilat3.txt ..\..\images\filter\Dilat3.txt
@if errorlevel 1 goto errorf 



filter /s /Mask /MaskSize 3 ..\..\images\filter\f_testM.txt MMsk3.txt /Format TXT#plain
@if errorlevel 1 goto errorf
gcomp MMsk3.txt ..\..\images\filter\MMask3.txt 
@if errorlevel 1 goto errorf 



filter /s /Gaus /MaskSize 1 ..\..\images\filter\Gaus.txt GGaus1.txt /Format TXT#plain
@if errorlevel 1 goto errorf
gcomp GGaus1.txt ..\..\images\filter\f_Gaus1.txt
@if errorlevel 1 goto errorf 

@rem filter /s /Gaus /MaskSize 2 ..\..\images\filter\Gaus.txt GGaus2.txt /Format TXT#plain
@rem @if errorlevel 1 goto errorf
@rem gcomp GGaus1.txt ..\..\images\filter\f_Gaus2.txt
@rem @if errorlevel 1 goto errorf 



del *.txt

@echo off

echo **** All filter tests passed ****



goto exit


:errorf

@echo off
echo !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
echo filtering of image has been failed
echo !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!


:exit
cd ..\..